<?php
/*
class DocPackage extends BaseDocPackage
{
    public function findByWords(array $words)
    {
        $q = ORMQuery::selectBuilder()
            ->from('DocPackage dp');
        foreach($words as $word) {
            $word = trim($word);
			$q ->orWhere('dp.name LIKE ?','%' . $word . '%');
			$q ->orWhere('dp.subpackage LIKE ?','%' . $word . '%');
			$q ->orWhere('dp.description LIKE ?','%' . $word . '%');
        }
        return $q->fetchAll('DocPackage');
    }
    
    public static function getPackageTree()
    {
        $tree = array();
        $pack = self::getAll();

        foreach ($pack as $p) {
            $arr = explode('-', $p->name);

            $count = count($arr);
            $last = &$tree;
            for ($i = 0; $i < $count; $i++) {
                if (!array_key_exists($arr[$i], $last)) {
                    $last[$arr[$i]] = array();
                }
                $last = &$last[$arr[$i]];
            }
            $last['package_info'] = $p;
        }
        return $tree;
    }

    public static function getPackageByName($name)
    {
        $q = ORMQuery::selectBuilder()
            ->from('DocPackage f')
            ->andWhere('f.name = ?', $name);
        return $q->fetchAll('DocPackage');
    }

    public static function getPackage($name, $subpackage)
    {
        $q = ORMQuery::selectBuilder()
            ->from('DocPackage f')
            ->andWhere('f.name = ?', $name)
            ->andWhere('f.subpackage = ?', $subpackage);
        return $q->fetch('DocPackage');
    }
    
    public function getSubpackages()
    {
        return self::getPackageByName($this->name);
    }
    
    public function getTodo()
    {
        $q = ORMQuery::selectBuilder()
            ->select('dt.*')
            ->from('Doctags dt')
            ->leftJoin( 'Doctype dref' , array( 'id','dt.doctype_id' ))
            ->leftJoin( 'DocPackage packref' , array( 'id','dref.package_id' ))
            ->andWhere( 'packref.id = ?', $this->id )
            ->andWhere( 'dt.name = ?', 'todo' );
        //print $this->id.' | '.$q; exit;
        return $q->fetchAll('Doctags');     
    }
    
    public function getClasses()
    {
        $q = ORMQuery::selectBuilder()
            ->select('pc.*')
            ->from('Phpclass pc')            
            ->leftJoin( 'Pfile fileref' , array( 'id','pc.file_id' ))
            ->leftJoin( 'DocPackage packref' , array( 'id','fileref.package_id' ))
            ->andWhere( 'packref.id = ?', $this->id )
            ->orderBy('pc.is_abstract DESC,pc.is_interface, pc.name');
        //print $this->id.' | '.$q; exit;
        return $q->fetchAll('Phpclass');    
    }

    public function getById($id)
    {
        return parent::getById($id, __CLASS__);
    }
    
    public function getByParams( $params, $type = self::ONE_RECORD, $limit = null )
    {
        return parent::getByParams( $params, $type, $limit, __CLASS__);
    }
    
    public function getAll( $limit = null )
    {
        return array();//parent::getAll( $limit, __CLASS__ );
    }

    public static function saveIfNotExists($params = null)
    {
        return parent::saveIfNotExists($params, __CLASS__);
    }
}*/